package com.nulldev.util.web.URLUtils.fuckTracking;

import java.net.HttpURLConnection;

import javax.net.ssl.HttpsURLConnection;

import com.nulldev.util.networking.ip.IP;
import com.nulldev.util.web.URLUtils.Entry;

public class FuckTracking {
	public static void protect(final HttpURLConnection conn) {
		if (conn == null) {
			return;
		}
		conn.setRequestProperty("X-Forwarded-For", IP.generateRandomIP());
		conn.setRequestProperty("HTTP_VIA", IP.generateRandomIP());
		conn.setRequestProperty("REMOTE_ADDR", IP.generateRandomIP());
	}

	public static void protect(final HttpsURLConnection conn) {
		if (conn == null) {
			return;
		}
		conn.setRequestProperty("X-Forwarded-For", IP.generateRandomIP());
		conn.setRequestProperty("HTTP_VIA", IP.generateRandomIP());
		conn.setRequestProperty("REMOTE_ADDR", IP.generateRandomIP());
	}

	public static Entry[] protect() {
		return new Entry[]
			{ new Entry("X-Forwarded-For", IP.generateRandomIP()), new Entry("HTTP_VIA", IP.generateRandomIP()),
					new Entry("REMOTE_ADDR", IP.generateRandomIP()) };
	}
}
